package com.card.game.dn;

import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;

import com.card.game.Card;

public class NnInfo implements Comparable<NnInfo>{
	public String userId;//玩家id
	public int qiangScore = -1;//抢庄
	public int betScore = -1;//下注分 
	public Vector<Card> cards;//当前手牌
	public int niuNum;//牛几
	public int winScore;//本局输赢 用于小局结束展示 

	public NnInfo(String userId) {
		this.userId = userId;
	}
	
	public void clear() {
		this.qiangScore = -1;
		this.betScore = -1;
		this.cards = null;
		this.winScore = 0;
	}

	public void setCards(Vector<Card> sours,int niuNum) {
		Vector<Card> cards = (Vector<Card>)sours.clone();
		Collections.sort(cards,new Comparator<Card>() {
			@Override
			public int compare(Card o1, Card o2) {
				if(o1.getIndex() == o2.getIndex()) {
					return o2.getType() - o1.getType();
				}
				return o1.getIndex() - o2.getIndex();
			}
		});
		this.cards = cards;
		this.niuNum = niuNum;
	}
	
	public Card getMaxCard() {
		if(this.niuNum == DzUtils.ZhanDan) {
			return cards.get(2);
		}
		return cards.get(4);
	}

	@Override
	public int compareTo(NnInfo o) {
		if(this.niuNum == o.niuNum) {
			Card c1 = getMaxCard();
			Card c2 = o.getMaxCard();
			if(c1.getIndex() == c2.getIndex()) {
				return c2.getType() - c1.getType();
			}
			return c1.getIndex() - c2.getIndex();
		}
		return this.niuNum-o.niuNum;
	}

	
}
